from tornado.web import Application, RequestHandler
import tornado.ioloop


class DetailHandler(RequestHandler):
    def get(self):
        ip = self.request.remote_ip  # 获取客户端的IP地址
        host = self.request.host  # 获取请求的主机地址
        result="ip地址为%s,host为%s"%(ip,host)
        return self.write(result)


if __name__ == '__main__':
    app = Application([
        ("/request", DetailHandler)
    ])
    app.listen(8888)
    tornado.ioloop.IOLoop.current().start()
